// arr.reduce(callback(accumulator, currentValue[, index[, array]])[, initialValue])

Array.prototype._reduce = function (callback, initialValue = 0) {
    let arr = Array.prototype.slice.call(this);
    let acc =  initialValue;
    for (let index = 0; index < arr.length; index++) {
        if (!arr.hasOwnProperty(index)) continue;
        //   ----------------acc, cur, index, src
        acc = callback.call(null, acc, arr[index], index, this)
    }
    return acc;
}


// case
var testArr = [1, 2, 3, 4]

var res = testArr._reduce((a, c) => a+c)
// var res = testArr.reduce((a, c) => a+c)

console.log(res)
// 10